const Mock = require('mockjs')
const listData = Mock.mock({
  'list|188': [
    {
      'id|+1': 1,
      tagname: '@ctitle'
    }
  ]
})
module.exports = [
  {
    url: '/mock/content/tag',
    type: 'get',
    response: (config) => {
      //   console.log(config.query.id)
      if (config.query.id) {
        const res = listData.list.find(item => item.id * 1 === config.query.id * 1)
        if (res) {
          return { code: 0, message: '', data: res }
        } else {
          return { code: 9997, message: '该数据不存在', data: res }
        }
      } else {
        let { page = 1, limit = 10 } = config.query
        page = page * 1
        limit = limit * 1
        const cloneList = JSON.parse(JSON.stringify(listData.list))
        const list = cloneList.splice((page - 1) * limit, limit)
        const total = listData.list.length
        return {
          code: 0,
          message: 'ok',
          data: {
            list,
            total
          }
        }
      }
    }
  }
]
